import argparse
import ipaddress

def find_neighborhood(AS, target_AS, as_links_file):
    all_links = []
    my_ASes = []
    my_links = []
    with open(origin_file, 'r') as links_file:
        line = links_file.readline()
        while (line):
            line = links_file.readline()
            all_links.append(line.split())
    while len(my_ASes) < max_ases:
        
    
            
def find_as_of_ip(ip, origin_file):
    ip_address = ipaddress.ip_address(ip)
    possibilities = []
    with open(origin_file, 'r') as origins_file:
        line = origins_file.readline()
        while (line):
            net = ipaddress.ip_network(line.split()[0])
            if ip_address in net:
                possibilities.append((net, line.split()[1]))
            line = origins_file.readline()
    max_net = max(map(lambda x: x[0], possibilities))
    return next(filter(lambda x: x[0] == max_net, possibilities))[1]
    

def main(ip, target_ip, output_file, origin_file, as_links_file):
    print (ip, target_ip, output_file, origin_file, as_links_file)
    AS = 5580#find_as_of_ip(ip,origin_file)
    ASES, links = find_neighborhood(AS, target_ip, as_links_file)
    print (AS)

if (__name__ == "__main__"):
    parser = argparse.ArgumentParser()
    parser.add_argument("ip", help="the ip to start with")
    parser.add_argument("target_ip", help="stops after this ip appears in the mini topology")
    parser.add_argument("output_file", help="path to output dml file")
    parser.add_argument("origin_file" , help = 'path to file containing ip perfixes per AS')
    parser.add_argument("as_links_file", help = 'path to file containing as links')
    args = parser.parse_args()
    main(**args.__dict__)